package usercontroller

import (
	"context"
	"gitee.com/go-mid/booter/bootservice"
	"gitee.com/go-mid/booter/web"
	"gitee.com/go-mid/infra/xlog"
	"gitee.com/go-mid/user/userservice"
)

// 查询
type GetUserLoginidRequest struct {
	userservice.GetUserLoginidReq
} //@name 获取用户登录凭证表请求

func FactoryGetUserLoginidRequest() web.HandleRequest {
	return new(GetUserLoginidRequest)
}

//
// @Summary      获取用户登录凭证表
// @Description  根据id获取用户登录凭证表详情
// @Tags
// @Param        message	body		GetUserLoginidRequest	true	"入参"
// @Success      200  {object}  web.ApiReturn{payload=userservice.GetUserLoginidRes} "响应"
// @Router       /user-loginid/get [post]
func (m *GetUserLoginidRequest) Handle(ctx context.Context, c *bootservice.Context, clientInfo web.XFRMClientInfo, authInfo web.XFRMAuthInfo) (interface{}, error) {
	fun := "UserLoginidController.GetUserLoginid -->"
	res, err := userservice.DefaultUserService.GetUserLoginid(ctx, &m.GetUserLoginidReq)
	if err != nil {
		xlog.Warnf(ctx, "%s DefaultUserService.GetUserLoginid err: req: %v  err: %v", fun, m, err)
		return nil, err
	}

	return res, nil
}

// 列表
type ListUserLoginidRequest struct {
	userservice.ListUserLoginidReq
} //@name 查询用户登录凭证表请求

func FactoryListUserLoginidRequest() web.HandleRequest {
	return new(ListUserLoginidRequest)
}

//
// @Summary      查询用户登录凭证表
// @Description  根据条件查询用户登录凭证表详情
// @Tags
// @Param        message	body		ListUserLoginidRequest	true	"入参"
// @Success      200  {object}  web.ApiReturn{payload=userservice.ListUserLoginidRes} "响应"
// @Router       /user-loginid/list [post]
func (m *ListUserLoginidRequest) Handle(ctx context.Context, c *bootservice.Context, clientInfo web.XFRMClientInfo, authInfo web.XFRMAuthInfo) (interface{}, error) {
	fun := "UserLoginidController.ListUserLoginid -->"
	res, err := userservice.DefaultUserService.ListUserLoginid(ctx, &m.ListUserLoginidReq)
	if err != nil {
		xlog.Warnf(ctx, "%s DefaultUserService.ListUserLoginid err: req: %v  err: %v", fun, m, err)
		return nil, err
	}

	return res, nil
}

// 添加
type AddUserLoginidRequest struct {
	userservice.AddUserLoginidReq
} //@name 添加用户登录凭证表请求

func FactoryAddUserLoginidRequest() web.HandleRequest {
	return new(AddUserLoginidRequest)
}

//
// @Summary      添加用户登录凭证表
// @Description  添加一条用户登录凭证表记录
// @Tags
// @Param        message	body		AddUserLoginidRequest	true	"入参"
// @Success      200  {object}  web.ApiReturn{payload=userservice.AddUserLoginidRes} "响应"
// @Router       /user-loginid/add [post]
func (m *AddUserLoginidRequest) Handle(ctx context.Context, c *bootservice.Context, clientInfo web.XFRMClientInfo, authInfo web.XFRMAuthInfo) (interface{}, error) {
	fun := "UserLoginidController.AddUserLoginid -->"
	res, err := userservice.DefaultUserService.AddUserLoginid(ctx, &m.AddUserLoginidReq)
	if err != nil {
		xlog.Warnf(ctx, "%s DefaultUserService.AddUserLoginid err: req: %v  err: %v", fun, m, err)
		return nil, err
	}

	return res, nil
}

// 修改
type UpdateUserLoginidRequest struct {
	userservice.UpdateUserLoginidReq
} //@name 修改用户登录凭证表请求

func FactoryUpdateUserLoginidRequest() web.HandleRequest {
	return new(UpdateUserLoginidRequest)
}

//
// @Summary      修改用户登录凭证表
// @Description  修改用户登录凭证表记录
// @Tags
// @Param        message	body		UpdateUserLoginidRequest	true	"入参"
// @Success      200  {object}  web.ApiReturn{payload=userservice.UpdateUserLoginidRes} "响应"
// @Router       /user-loginid/update [post]
func (m *UpdateUserLoginidRequest) Handle(ctx context.Context, c *bootservice.Context, clientInfo web.XFRMClientInfo, authInfo web.XFRMAuthInfo) (interface{}, error) {
	fun := "UserLoginidController.UpdateUserLoginid -->"
	res, err := userservice.DefaultUserService.UpdateUserLoginid(ctx, &m.UpdateUserLoginidReq)
	if err != nil {
		xlog.Warnf(ctx, "%s DefaultUserService.UpdateUserLoginid err: req: %v  err: %v", fun, m, err)
		return nil, err
	}

	return res, nil
}

// 添加或修改
type UpsertUserLoginidRequest struct {
	userservice.UpsertUserLoginidReq
} //@name 添加或修改用户登录凭证表请求

func FactoryUpsertUserLoginidRequest() web.HandleRequest {
	return new(UpsertUserLoginidRequest)
}

//
// @Summary      添加或修改用户登录凭证表
// @Description  添加或修改用户登录凭证表记录
// @Tags
// @Param        message	body		UpsertUserLoginidRequest	true	"入参"
// @Success      200  {object}  web.ApiReturn{payload=userservice.UpsertUserLoginidRes} "响应"
// @Router       /user-loginid/upsert [post]
func (m *UpsertUserLoginidRequest) Handle(ctx context.Context, c *bootservice.Context, clientInfo web.XFRMClientInfo, authInfo web.XFRMAuthInfo) (interface{}, error) {
	fun := "UserLoginidController.UpsertUserLoginid -->"
	res, err := userservice.DefaultUserService.UpsertUserLoginid(ctx, &m.UpsertUserLoginidReq)
	if err != nil {
		xlog.Warnf(ctx, "%s DefaultUserService.UpsertUserLoginid err: req: %v  err: %v", fun, m, err)
		return nil, err
	}

	return res, nil
}
